<template>
  <el-dialog title="修改职员绩效考核" :visible.sync="dialogVisible" width="50%">

    <el-form ref="form" :model="form" label-width="80px">
      <el-form-item label="被考核人">
        <el-select v-model="form.bkhrId" placeholder="请选择">
          <el-option v-for="bkhr in bkhrs" :key="bkhr.id" :label="bkhr.nickname" :value="bkhr.id">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="考核人">
        <el-select v-model="form.khrId" placeholder="请选择">
          <el-option v-for="khr in khrs" :key="khr.id" :label="khr.nickname" :value="khr.id">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="考核等级">
        <el-select v-model="form.grade" placeholder="请选择">
          <el-option  label="优秀"  :value="0">优秀</el-option>
		  <el-option  label="良好" :value="1">良好</el-option>
		  <el-option  label="普通" :value="2">普通</el-option>
		  <el-option  label="未完成" :value="3">未完成</el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="考核时间">
        <el-date-picker v-model="form.time" type="date" placeholder="选择日期">
        </el-date-picker>
      </el-form-item>
    </el-form>

    <span slot="footer" class="dialog-footer">
      <el-button @click="dialogVisible = false">取 消</el-button>
      <el-button type="primary" @click="update1()">确 定</el-button>
    </span>
  </el-dialog>
</template>

<script>
  export default {
    name: "updatePer",
    data() {
      return {
        dialogVisible: false,
        header:{token:window.sessionStorage.getItem('token')},
        form: {
		  id:"",
          bkhrId: "",
		  bkhrName: "",
          khrId: "",
		  khrName: "",
          time: "",
          grade: "",
          operUser: "",
          operTime: ""
        },
		khrs: [],
		bkhrs: []
      };
    },
    methods: {
      update1() {
        var that = this;
        //向后端发送ajax请求,提交表单的数据   json格式提交 name=11&pwd=11
        this.$http.post('/performance/update', that.form).then(function(res) { //回调
          that.dialogVisible = false;
          window.location.reload();
        });
      },
	  findPerInfo(id){
	    var that = this;
	    //查询要修改的用户信息
	    this.$http.get("/performance/getPer/"+id).then(function(res) {
	        that.form.bkhrId = res.data.per.bkhrId;
	        that.form.khrId = res.data.per.khrId;
	        that.form.time = res.data.per.time;
	        that.form.grade = res.data.per.grade;
	    })
	  }
    },
    created() {
      var _this = this
      //查询考核人
      this.$http.get("/performance/getkhrs").then(function(res) {
        _this.khrs = res.data.khrs;
      })
      //查询被考核人
      this.$http.get("/performance/getbkhrs").then(function(res) {
        _this.bkhrs = res.data.bkhrs;
      })
    }
  };
</script>

<style>
  .avatar-uploader .el-upload {
  	    border: 1px dashed #d9d9d9;
  	    border-radius: 6px;
  	    cursor: pointer;
  	    position: relative;
  	    overflow: hidden;
  	  }
  	  .avatar-uploader .el-upload:hover {
  	    border-color: #409EFF;
  	  }
  	  .avatar-uploader-icon {
  	    font-size: 28px;
  	    color: #8c939d;
  	    width: 178px;
  	    height: 178px;
  	    line-height: 178px;
  	    text-align: center;
  	  }
  	  .avatar {
  	    width: 178px;
  	    height: 178px;
  	    display: block;
  	  }
</style>
